home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Applications / TimGA 1.2.1 / .h / MyUtils.h < prev   
Encoding:
Text File  |  1997-07-16  |  2.3 KB  |  79 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    MyUtils.h        ©1995-97 Timo Eloranta            All rights reserved.
  3. // ===========================================================================
  4. //    MyUtils.cp        (press Command-Tab to open the associated source file)
  5.  
  6. #pragma once
  7.  
  8. #include <PP_Types.h>
  9.  
  10. void            ToggleMenuItem( CommandT    inCommand,
  11.                                 ResIDT        inStringID );
  12.  
  13. Boolean            MyPtInRect( Int16 inX, Int16 inY, const Rect *inRect );
  14.  
  15. pascal OSErr    PlayOneSnd( ResIDT inSoundID, Boolean inAsync );
  16.  
  17. Int16            RangedRdm  ( Int16 inMin, Int16 inMax );
  18. Int16            FastRandom ( Int16 inRange );
  19. Boolean            RandomBool ( void );
  20.  
  21. void            LineFromTo ( Int16 xFrom, Int16 yFrom, Int16 xTo, Int16 yTo);
  22.  
  23.  
  24. // ===========================================================================
  25. // • Inline Functions
  26. // ===========================================================================
  27.  
  28. // ---------------------------------------------------------------------------
  29. //        • RangedRdm
  30. //
  31. //          Called by:    CGraphDrawing::Mutate
  32. //                        CGraphDrawing::ThreeConnectedNodes
  33. //                        CGraphNodes::Initialize
  34. //                        CGraphNodes::SingleMutate etc.
  35. //                        CPopulation::SetUpEdges
  36. //                        CPopulation::SelectOne etc.
  37. // ---------------------------------------------------------------------------
  38.  
  39. inline Int16 
  40. RangedRdm( Int16 inMin, Int16 inMax)
  41. {
  42.     Int16    theRange = (inMax - inMin) + 1;    // OVERFLOW POSSIBLE
  43.                                             // IF USED WITH BIG VALUES !!!
  44.     
  45.     return    inMin + FastRandom( theRange );
  46. }
  47.  
  48. // ---------------------------------------------------------------------------
  49. //        • RandomBool
  50. //
  51. //          Called by:    CGraphDrawing::EdgeMutation
  52. //                        CGraphDrawing::TwoEdgeMutation
  53. //                        CGraphNodes::MoveEdge
  54. //                        CGraphNodes::Move3ConnectedNodes
  55. //                        CPopulation::DoCrossover
  56. //                        CPopulation::DoRectCrossover
  57. // ---------------------------------------------------------------------------
  58.  
  59. inline Boolean 
  60. RandomBool( void )
  61. {
  62.     return FastRandom( 2 );
  63. }
  64.  
  65. // ---------------------------------------------------------------------------
  66. //        • LineFromTo
  67. //
  68. //          Called by:    CEdge::Draw
  69. //                        CGraphPane::DrawGrid
  70. // ---------------------------------------------------------------------------
  71.  
  72. inline void 
  73. LineFromTo (Int16 xFrom, Int16 yFrom,
  74.             Int16 xTo,      Int16 yTo)
  75. {
  76.     ::MoveTo( xFrom, yFrom );
  77.     ::LineTo( xTo, yTo );
  78. }
  79.